LIKE Filtering And Performance Question/Dependency Caching?
Apr 11, 2006
Today I was asked a question I couldn't answer [it happens all the time...more than I like to admit...] concerning the performance hit of the SQL LIKE Filter.
The question was, what is the performance hit you take when you, say filter the results of a gridview control, with a LIKE FILTER in a stored procedure in SQL SERVER 2005?
Would it be preferable to create a Dependency Cache of a DataSet or a DataView object and then perform some type of filtering operation on that?
Hello, I have caching enabled in my application and I am using SqlCacheDependency to cache my tables. Well, the cache works fine but when the table is updated the information in my cache does not update. I DO have the broker service started and running but not sure what else i am missing. I am using sql server 2005.
Hey, I can't enable caching on my local computer..I use daspnet_regsql -S "localhostSQLEXPRESS" -E -d books -edand aspnet_regsql -S "AdminSQLEXPRESS" -E -d books -edto try to start but i get a login error...cannot open database "books" requested by login. The login failed. Login failed for user Computer2/Adminunable to connect to SQL database for cache dependency registrationI tested connection with vwd and sql express management and it connects so I don't know what i'm doing wrong since I followed the direction and I googled for answer but not coming up with anything that's helping me..anyone have this problem and know how to resolve so i can cache some data output on my project
Probably a dumb question, but if one is using SQL Server 2000 instead of 'SQL Express' what has to change here, in order to set up caching? What changes in the paths?
I am building a web app using VS2005 and SQL 2005 I would like to use the Caching Application Block to cache objects from my BLL. I was wondering if there is a way of utilizing the build in SQLDependency in SQL 2005 with the Caching Application Block??? Does anybody have tried this, are there any samples on the web???
i have a report with approximately 20 reportparameters from queries. This is really slowing down the system, although the dataload (rows sent back) is not that huge. I read on the internet that there are basicly three approaches.
1, Query parameter with alot of diffrent datasources
2, Table filtering
3, Stored procedures
I wonder which approach is the best and why it takes such a long time to get the report with the report parameters (before generating the report itself).
Hi All,I have an application that reads data from a very slow database link(like 10 seconds per call) though what I am looking for would be ofgeneric use for anyone who has long-running queries that arefrequently repeated.I would like to be able to cache the results of a query so that I donot have to re-execute that query if it is reissued. Ideally Ibelieve that this could be implemented by hiding the query inside aUDF and exposing the UDF through a view. The UDF could then "Checkthe cache" and only run the slow query if there wasn't a match (or ifthe match was too old). From what I understand the best way to dothis would be for the cache to be an extended stored procedure.Has anyone done or seen this? Has someone written a copy that Icould purchase? Does anyone care to offer their opinnion of how or ifthis could work?Thanks in Advance,Steven
Hello All, I want to use SQLDataSource as a base of all Gridview in my application. I have read that SQLDataSource support caching. I want to know as SQLDataSource is a child control of page class. It will get unloaded when page is unloaded. So how caching works. Like I am using SQLDataSource as base of my GridView control. When I perform paging or sorting,In theory It says that It will not hit the Datbase again. It will keep that Data in memory as DataSet, but this will stay alive upto life of page, which starts again and again when a page is requested, So as its child controls. Can anybody give me more intrinsics on this. Any Help from Microsoft is appreciated !!!! Thanks !!
I know I can use the SqlDataSource object and cache the results by setting it's enableCache property to true, but what if I am using essentially the same SqlDataSource control across multiple pages? For instance I have a States SqlDataSource on many pages in my site, if I enable caching on all of these objects won't they all be cached separately? Is the solution to not use the SqlDataSource and instead cache the datatable of results and bind the dropdownlists to that? Thanks in advance.
Hi Expert, Am I doing it right? Can you give me any suggestions please? Thank you!!I followed the way for setting up the sql cache dependency from http://quickstarts.asp.net/QuickStartv20/aspnet/doc/caching/SQLInvalidation.aspx.However, I still have the following error: When using SqlDependency without providing an options value, SqlDependency.Start() must be called prior to execution of a command added to the SqlDependency instance. IssueSummary.aspx<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="IssueSummary.aspx.vb" Inherits="IssueSummary" title="Issue Summary" %><%@ Register Assembly="AtlasControlToolkit" Namespace="AtlasControlToolkit" TagPrefix="cc2" %><%@ Register Assembly="Microsoft.Web.Atlas" Namespace="Microsoft.Web.UI" TagPrefix="cc1" %><%@ OutputCache Duration="999999" VaryByParam="None" SqlDependency="CommandNotification" %> Global.asaxSub Application_Start(ByVal sender As Object, ByVal e As EventArgs)Dim connectionString As String = ConfigurationManager.ConnectionStrings("ICTConnectionString").ConnectionStringDim needToInstall As Boolean = TrueTryDim tables() As Stringtables = SqlCacheDependencyAdmin.GetTablesEnabledForNotifications(connectionString)If (Not tables Is Nothing) ThenDim tbl As StringFor Each tbl In tablesIf (tbl.ToLower().Equals("IssueDetails")) ThenneedToInstall = FalseEnd IfNextEnd IfCatch ex As ExceptionneedToInstall = TrueEnd TryIf (needToInstall) ThenSqlCacheDependencyAdmin.EnableNotifications(connectionString)SqlCacheDependencyAdmin.EnableTableForNotifications(connectionString, "IssueDetails")End IfEnd Sub Web.config<connectionStrings><add name="ICTConnectionString" connectionString="Data Source=jamesle-3;Initial Catalog=IssueCommunicationTool;Integrated Security=True" providerName="System.Data.SqlClient"/></connectionStrings><system.web><caching><sqlCacheDependency enabled="true" pollTime="1000" ><databases><add name="ICTDB" connectionStringName="ICTConnectionString" /></databases></sqlCacheDependency></caching> SQL Server 2005 - Database - IssueCommunicationToolSELECT is_broker_enabled FROM sys.databases WHERE name = 'IssueCommunicationTool' Return = 1, it means the broker service is enabled. Also, the database has created the table ASPNET_SQLCacheTableForChangeNotification, the trigger in IssueDetails table, and some other store procedures.
I have a control that shows the top 5 best selling products. Thes list does not need to be up to date at all times. Ideally I would like to cache the data for say 24hr before pulling it again if someone accesses the control. I thought there was an easy way to do this, but I can't seem to find anything. Can anyone point me in the right direction.
Hi, I'm trying to set up a SqlCacheDependency using the Query notifications of SQL Server 2005. I haven't even got to the point of testing the notifications part. My problem is that my DataTable is not even getting stored in the cache when I insert it. The cache seems to be getting invalided as soon as I add the DataTable. Here is my code: (am trying to get a simple example working first)protected void Page_Load(object sender, EventArgs e) { DataTable results = (DataTable)HttpRuntime.Cache.Get("supplyFunctions"); if (results == null) { Response.Write("Cache Invalidated, hitting DB. TIME: " + DateTime.Now.ToString()); results = getSupplyFunctions(); } else { Response.Write("got from Cache, TIME: " + DateTime.Now); } GridView1.DataSource = results; GridView1.DataBind(); }private DataTable getSupplyFunctions() { DataTable results = new DataTable(); using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ToString()) ) { using (SqlCommand command = connection.CreateCommand()) { command.CommandText = "schema.myStoredProc"; command.CommandType = CommandType.StoredProcedure; SqlCacheDependency dependency = new SqlCacheDependency(command); SqlDataAdapter adapter = new SqlDataAdapter(); adapter.SelectCommand = command; DataSet dataset = new DataSet(); adapter.Fill(dataset); results = dataset.Tables[0]; HttpRuntime.Cache.Insert("supplyFunctions", results, dependency); }
} return results; } Also, whats weird is that when I keep refreshing the page, after like 5 to 10 minutes it works, and starts caching the data. This disturbs me-- I would like to know what is going on. I am pretty sure my stored procedure doesn't break the rules of the query notifications. Can someone help me out?!??! Thanks!
I have a page in my website that pulls content for a newsletter from a SQL Server 2000 database using a SqlDataSource and a FormView. I add a new newsletter every week. Other than that weekly addition, no changes are really ever needed or made to the data. Scott Gu says every application can and should make use of caching and I would like to add some kind of caching to improve the performance of this page. I have read about SqlCacheDependency with SQL 2000, but if I understand it correctly, it will poll the database for changes every x seconds, an expensive operation that I just don’t need; the data only changes once a week. I’ve seen some code examples using DataSets and the Cache API but I’m really just looking for a simple, mostly declarative solution using the SqlDataSource. Theoretically, I would like the data cached forever until I insert a new item. I have set the following cache-related properties on my SqlDataSource as follows:
Setting these properties seems to work great for caching the data but how do I programmatically invalidate the cache when a new item is inserted? I have a separate admin page with a FormView that I use to insert the newsletter each week. Is there some kind of code that I could put in the ItemInserted event that would invalidate the cache so that the new item will be displayed and then cached? I don't have any experience with caching; where am I going wrong? Are my expectations unrealistic? Thank you in advance to anyone who can shed some light on this issue.
I've recently deployed an ASP.Net application, with admittedly not a lot of experience with SQL Server 2005 caching.A problem that I ran into is a user searching for a case number very soon after entering it, and it not showing up. However, after a few minutes and re-running the search it appeared.I'm guessing that this is a SQL Server caching issue, but I'm not sure what to do about it.On my search screen, I have a listview for the results, a textbox for the case # input, a button and a sqldatasource. The SqlDataSource uses a select statement, and two parameters for user(ensure the case belongs to that user) and casenumber. The SqlDataSource has enablecaching set to false. Any ideas what I can do about this issue? Also, any good places I can read about sql server caching? Thanks
I'm trying to performance tune a procedure and am sort of being thwarted by caching.
When I first run the procedure, it takes a few seconds which is too long in this case. Subsequent executions in Management Studio are nearly instantaneous, though, which I imagine is due to caching and does not reflect the behavior of the procedure in production.
Is there a way to disable caching so that each execution of the procedure in Management Studio will be consistent and reflect the "first run" performance?
Is there a way to manage the cache when a file is being FTP'd from a server? It writes the file to the d: drive but caches it to c: first. Can I add a command line switch to tell it not to cache the file first?
Is it possible expire a report cache after less than one minute? I'm looking for a way to only have a report hit the database once every 10 seconds, no matter how many people are hitting it. Thanks.
If i use the caching feature of the report. is there a way i can find or set in the report itself if the user if renedered from cache or actually connected to the database.
i mean if ON the Caching, for the 1st user the data will come from DB and the report manager stores the report in cache. next user if he tries to connect should get a message that the report was rendered from cache - taken 5 min back.
I have SQL Server 2005 and I am using .Net 2.0. Is there a way to cache a query, basically I am going to do a SELECT * on a table that is called frequently. I then want to query this DataTable that is in cache. I want to invalidate the cache when the table changes. Everything I have read tells me to use the output caching directive. But, much of what I am doing doesn't end up in the output. Is there a way to invalidate the cache the same way without output caching and using the Service Broker?
Hi everyone!I tried to set my SqlDataSource's SelectCommandType to be a stored procedure. However the SqlDataSource failed to cache it. But if I just copy paste my stored procedure's content to my SqlDataSource's SelectCommand property, the cache just works. Is "StoredProcedure" as the "SelectCommandType" is not supported when caching the data? Or am I missing something here? Please help.
Hello all, I've got an application that calls a really simple stored procedure - just selects all records from the dbase. The problem is this seems to cache every now and then and as the same table is updated very frequently by other users this means the data returned isn't up to date. I thought it was Sql Server caching the results of the stored procedure, but I can do an iisreset and it will be up to date again. And unless I'm missing some point iisreset has no bearing on Sql Server. So is there an application data cache somewhere that I should be clearing to ensure the recordset is always up to date?
I'm in the process of optimizing a fairly large ASP.Net App. One of the things I want to do is enable SQL Dependancy caching. I've set this up fine SQL2005 side but need a bit of advice .Net Side. I know if you use the SqlDataSource class you can set it to use the caching, unfortunatly this projects Datalayer uses the SqlDataAdapter is there any way of making this use SqlDependancy chacing? Hope that makes sense and doesnt sound too dumb. Thanks
Hi..I have a large database which powers an old ASP website, until I have time to migrate the old ASP pages over to .NET I was wondering if I am able to use any caching settings in SQL Express 2005??What I mean is, can I long in to SQL using the management interface - And set up some sort of caching for the databases I have in there? I wanted to cache the database for say 10 seconds.. As I get alot of hits on the site and this would help speed things up / save resources.Any tips / help appreciated...ThanksAlso I don't want to get into hacking around with the ASP code... As I am in the middle of migrating the pages, hence I was hoping this would be the quickest way if it was possible
Hello, every one! This is my first post on the forum. I got some questions about caching data with SqlDataSource controls in asp.net 2005. Here are them: According to the vs.net 2005 documents, SqlDataSource controls will sustain an individual cache for each combination of ConnectionString, SelectCommand and values of SelectParameters. But how about FilterExpression and FilterParameters? If I enable caching and change the FilterExpression or values of FilterParameters, will the SelectCommand be reexcuted, or will the databinding controls just get data from the existing cache? And will multiple SqlDataSource controls with the same combination of ConnectionString, SelectCommand and values of SelectParameters share a common cache, or sustain caches of their own?
Hi All, Heres my problem... If I create a table T1 with a couple of columns; MyPKCol, ColA I then create a view V1 as "Select * From T1" At this stage, if I run "Select * From V1" the result will, as expected, include following columns: MyPKCol,ColA
If I now add another column, ColB, to T1 and then again run "Select * From V1", I still get the result with only 2 columns; MyPKCol,ColA
In order for V1 to return MyPKCol,ColA,ColB I have to drop V1 and then recreate it again.
Can someone explain why this is and how I can clear this type of cache? I've tried the following commands, but it didn't work: DBCC FREEPROCCACHE; DBCC FREEsystemCACHE( 'ALL' ); DBCC DROPCLEANBUFFERS;
There has to be an easier way than having to recreate SPs, Function and Views just because you make a change to a table.
I hope I made sence Thank you in advance for any help.
I am not sure this is the right forum for this question, but I would appreciate any pointers towards more appropriate forums.
I am attempting to replicate the data browsing performance of Microsoft's QA/SSMS in my own application. Even for very large datasets, one can typically scroll through a few hundred thousands rows without a problem. For queries this large, a generic DataGridView setup would take forever. Digging around using Process Explorer, I saw that QA/SSMS was loading the results into a (what I presume to be a memory-mapped) temporary file, which it used to cache the results for display.
Is there an example of how this is being done? I am assuming it is using unmanaged code, as I am not aware of any interfaces to memory mapped files in .NET. I don't have much experience here, so I would appreciate any help. Thanks.