Showing posts with label hit. Show all posts
Showing posts with label hit. Show all posts

Friday, March 30, 2012

Problem with SqlCacheDependency

I've set up a SqlCacheDependency in my Asp.Net application, but the dependency invalidates the cache immediately every time the page is hit.

I think the problem may be with my SQL Query, but it seems to me to meet the requirements on the Special Considerations When Using Query Notifications page on MSDN. Could someone take a look at this query and tell me if I've done something wrong? Thank you.

Here's my query:

Code Snippet

USE [chameleon]

GO

SET ANSI_NULLS ON

GO

SET ANSI_PADDING ON

GO

SET ANSI_WARNINGS ON

GO

SET CONCAT_NULL_YIELDS_NULL ON

GO

SET QUOTED_IDENTIFIER ON

GO

SET NUMERIC_ROUNDABORT OFF

GO

SET ARITHABORT ON

GO

ALTER PROCEDURE [dbo].[usp_customers_by_site_id]

@.site_id INT

AS

SELECT

customers.customer_id,

customers.name,

customers.po_prefix,

customers.dt_created,

customers.created_by AS auid,

customers.po_required

FROM dbo.customers

WHERE customers.site_id = @.site_id

AND customers.is_active = 1

and here's the code in my Asp.Net site where I try to use the SqlCacheDependency:

Code Snippet

public List<Customer> GetCustomersBySite(int siteID)

{

List<Customer> customers = new List<Customer>();

if (HttpRuntime.Cache["CustomersBySite" + siteID] != null){

customers = (List<Customer>)HttpRuntime.Cache["CustomersBySite" + siteID];

}

else

{

using (SqlCommand command = new SqlCommand("usp_customers_by_site_id", Connection)){

command.CommandType = CommandType.StoredProcedure;

command.Parameters.Add("@.site_id", SqlDbType.Int).Value = GetDBValue(siteID, false);

SqlCacheDependency dependency = new SqlCacheDependency(command);

try{

Connection.Open();

SqlDataReader reader;

reader = command.ExecuteReader(CommandBehavior.SingleResult);

while (reader.Read()){

customers.Add(PopulateCustomer(reader));

}

HttpRuntime.Cache.Insert("CustomersBySite" + siteID, customers, dependency, DateTime.Now.AddMinutes(Configuration.CacheDuration), System.Web.Caching.Cache.NoSlidingExpiration);

}

finally{

Connection.Close();

}

}

}

return customers;

}

My apologies. I posted this in the wrong forum.

-Brad

Tuesday, March 20, 2012

Problem with scripting in SQL 2005 after SP2

Hello everyone,
We hit a snag after installing SP2 for SQL Server 2005 Standard. Basically,
when we want to script the database the server takes ages to determine
objects in the database and then it takes another age to actually script the
objects.
Before the SP2 scripting was lightning fast. Now we dread any change that
would require scripting.
Any help and/or insight much appreciated.
BR,
GAZ
> Before the SP2 scripting was lightning fast. Now we dread any change that
> would require scripting.
I find Red-Gate's SQL Compare to be very fast at generating change scripts.
Yes, it is not free, but it beats Management Studio's output hands down.
Anyway, here's something from Erland that I posted in the .Tools newsgroup
just yesterday:
[vbcol=seagreen]
I haven't tested scripting with SP2 as far as I can recall, but a tip
is that setting the database in forced parameterisation, can speed up
scripting considerably, since MgmtStudio uses inlined parameter values.
See also
http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=247968[vbcol=seagreen]
Aaron Bertrand
SQL Server MVP
http://www.sqlblog.com/
http://www.aspfaq.com/5006
|||Thanks for the tip. Changing the property Parametarisation to Forced has
resolved the issue. Scripting is a pleasurable task once again.
Thanks.
GAZ
"Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:O$UD4VcgHHA.284@.TK2MSFTNGP05.phx.gbl...
> I find Red-Gate's SQL Compare to be very fast at generating change
> scripts. Yes, it is not free, but it beats Management Studio's output
> hands down.
> Anyway, here's something from Erland that I posted in the .Tools newsgroup
> just yesterday:
> I haven't tested scripting with SP2 as far as I can recall, but a tip
> is that setting the database in forced parameterisation, can speed up
> scripting considerably, since MgmtStudio uses inlined parameter values.
> See also
> http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=247968
> --
> Aaron Bertrand
> SQL Server MVP
> http://www.sqlblog.com/
> http://www.aspfaq.com/5006
>

Problem with scripting in SQL 2005 after SP2

Hello everyone,
We hit a snag after installing SP2 for SQL Server 2005 Standard. Basically,
when we want to script the database the server takes ages to determine
objects in the database and then it takes another age to actually script the
objects.
Before the SP2 scripting was lightning fast. Now we dread any change that
would require scripting.
Any help and/or insight much appreciated.
BR,
GAZ
> Before the SP2 scripting was lightning fast. Now we dread any change that
> would require scripting.
I find Red-Gate's SQL Compare to be very fast at generating change scripts.
Yes, it is not free, but it beats Management Studio's output hands down.
Anyway, here's something from Erland that I posted in the .Tools newsgroup
just yesterday:
[vbcol=seagreen]
I haven't tested scripting with SP2 as far as I can recall, but a tip
is that setting the database in forced parameterisation, can speed up
scripting considerably, since MgmtStudio uses inlined parameter values.
See also
http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=247968[vbcol=seagreen]
Aaron Bertrand
SQL Server MVP
http://www.sqlblog.com/
http://www.aspfaq.com/5006
|||Thanks for the tip. Changing the property Parametarisation to Forced has
resolved the issue. Scripting is a pleasurable task once again.
Thanks.
GAZ
"Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:O$UD4VcgHHA.284@.TK2MSFTNGP05.phx.gbl...
> I find Red-Gate's SQL Compare to be very fast at generating change
> scripts. Yes, it is not free, but it beats Management Studio's output
> hands down.
> Anyway, here's something from Erland that I posted in the .Tools newsgroup
> just yesterday:
> I haven't tested scripting with SP2 as far as I can recall, but a tip
> is that setting the database in forced parameterisation, can speed up
> scripting considerably, since MgmtStudio uses inlined parameter values.
> See also
> http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=247968
> --
> Aaron Bertrand
> SQL Server MVP
> http://www.sqlblog.com/
> http://www.aspfaq.com/5006
>

Problem with scripting in SQL 2005 after SP2

Hello everyone,
We hit a snag after installing SP2 for SQL Server 2005 Standard. Basically,
when we want to script the database the server takes ages to determine
objects in the database and then it takes another age to actually script the
objects.
Before the SP2 scripting was lightning fast. Now we dread any change that
would require scripting.
Any help and/or insight much appreciated.
BR,
GAZ> Before the SP2 scripting was lightning fast. Now we dread any change that
> would require scripting.
I find Red-Gate's SQL Compare to be very fast at generating change scripts.
Yes, it is not free, but it beats Management Studio's output hands down.
Anyway, here's something from Erland that I posted in the .Tools newsgroup
just yesterday:
[vbcol=seagreen]
I haven't tested scripting with SP2 as far as I can recall, but a tip
is that setting the database in forced parameterisation, can speed up
scripting considerably, since MgmtStudio uses inlined parameter values.
See also
http://connect.microsoft.com/SQLSer...edbackID=247968[vbcol=se
agreen]
Aaron Bertrand
SQL Server MVP
http://www.sqlblog.com/
http://www.aspfaq.com/5006|||Thanks for the tip. Changing the property Parametarisation to Forced has
resolved the issue. Scripting is a pleasurable task once again.
Thanks.
GAZ
"Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in mess
age
news:O$UD4VcgHHA.284@.TK2MSFTNGP05.phx.gbl...
> I find Red-Gate's SQL Compare to be very fast at generating change
> scripts. Yes, it is not free, but it beats Management Studio's output
> hands down.
> Anyway, here's something from Erland that I posted in the .Tools newsgroup
> just yesterday:
>
> I haven't tested scripting with SP2 as far as I can recall, but a tip
> is that setting the database in forced parameterisation, can speed up
> scripting considerably, since MgmtStudio uses inlined parameter values.
> See also
> http://connect.microsoft.com/SQLSer...=247
968
> --
> Aaron Bertrand
> SQL Server MVP
> http://www.sqlblog.com/
> http://www.aspfaq.com/5006
>

Problem with scripting in SQL 2005 after SP2

Hello everyone,
We hit a snag after installing SP2 for SQL Server 2005 Standard. Basically,
when we want to script the database the server takes ages to determine
objects in the database and then it takes another age to actually script the
objects.
Before the SP2 scripting was lightning fast. Now we dread any change that
would require scripting.
Any help and/or insight much appreciated.
BR,
GAZ> Before the SP2 scripting was lightning fast. Now we dread any change that
> would require scripting.
I find Red-Gate's SQL Compare to be very fast at generating change scripts.
Yes, it is not free, but it beats Management Studio's output hands down.
Anyway, here's something from Erland that I posted in the .Tools newsgroup
just yesterday:
I haven't tested scripting with SP2 as far as I can recall, but a tip
is that setting the database in forced parameterisation, can speed up
scripting considerably, since MgmtStudio uses inlined parameter values.
See also
http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=247968
--
Aaron Bertrand
SQL Server MVP
http://www.sqlblog.com/
http://www.aspfaq.com/5006|||Thanks for the tip. Changing the property Parametarisation to Forced has
resolved the issue. Scripting is a pleasurable task once again.
Thanks.
GAZ
"Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:O$UD4VcgHHA.284@.TK2MSFTNGP05.phx.gbl...
>> Before the SP2 scripting was lightning fast. Now we dread any change that
>> would require scripting.
> I find Red-Gate's SQL Compare to be very fast at generating change
> scripts. Yes, it is not free, but it beats Management Studio's output
> hands down.
> Anyway, here's something from Erland that I posted in the .Tools newsgroup
> just yesterday:
> I haven't tested scripting with SP2 as far as I can recall, but a tip
> is that setting the database in forced parameterisation, can speed up
> scripting considerably, since MgmtStudio uses inlined parameter values.
> See also
> http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=247968
> --
> Aaron Bertrand
> SQL Server MVP
> http://www.sqlblog.com/
> http://www.aspfaq.com/5006
>