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
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.
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.
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'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.
My .NET SQL UDF needs do very complex computation on every call regardless on user input. I would be very happy if I could cache this computed data somewhere in SQL Server memory. And then I should not need to recompute this complex information on every UDF call. Is it possible to cache something inside SQL Server from CLR ?
I wrote an invoice report that gets its data from an Oracle database. This is working fine except when users change something on the server (like adding a new charge to the invoice) then when they re-run the SSRS report the new line doesn't show up. They wait 15 minutes and re-run the SSRS report and then it appears.
It is like the SSRS report is caching the old data of the report.
Points to note though...
To execute the report I am using the SSRS 2005 webservice. I understand that there is 2 cachings, 1 server and 1 IIS side. I have not cached the server and don't know how to clear the IIS side. I see there is a rs:ClearSession=true parameter that you can pass in but by using the SSRS 2005 webservice this is not an option (I don't see how you can pass query strings in to the call).
I have a report which is being cached at the report server level. After the cache expires I use the Null Delievery Method to repopulate cache for faster report viewing. The report has two parameters Brand and Region. Say for eg for a Particular brand A there are two geographies North and South then at a given time the drill down in the report only works for one of the parameters i.e either North or South. For the other the results are erratic i.e half of the rows are not shown or the drill down doesnt work at all. Initially i thought that this was a known issue so installed SP1 to solve but the problem is still there. The report works Flawlessly if run without Caching. This problem only occurs when i turn on the Caching.
Does anyone know the solution to this problem as this is becoming sort of a roadblock.
I'm just starting to look into using Reporting Services for our reporting needs; however I hope someone can answer the following question for me.
Is it possible to set a separate cache time for each report?
We are working on a company portal and due to the stored procedures that produce certain reports we need to set a cache time that might be shorter for one report than the next. Is this possible?
Hi all,I have a database with 40GB of binary objects stored in image columnsin two tables.Our database server is also used for another 15 databases.SQL Server caches the image-column, causing the cache-hit-ratio todramatically decrease, since fetching a couple of binaries from theimage-column uses up thememory, and throws other cached objects out of the cache.Is there a way, and could someone tell me how, to avoid caching ofspecificcolumns/tables?Regards///Magnus