query-execution-plans

Query cost relative to batch is 100%

I'm not sure sure how to interpret this, but all the queries I run in sql server 2005 have a "query cost (relative to batch)" of 100%. Is there any way to reduce the cost? ...

Getting around cached plans in SQL Server 2005

Can someone please explain why this works. Here is the scenerio. I have a stored proc and it starts to run slow. Then I pick a parameter and declare a variable to house its value and in the proc use the declared variable instead of the parameter. The proc will then speed up considerably. I think it has something to do with the cache...

How to store query execution plan so that they can be used later

My applications runs queries against a sql server database. In many cases I can see the benefit of an execution plan: for example I click for the first time on a button to SELECT * from Tasks WHERE IdUser = 24 AND DATE < '12/12/2010' and DATE > '01/01/2010' it takes 15 seconds the first time, 8 seconds the following times. EDIT: ...

Interpreting an execution plan

Hello, I need some help analysing some simple t-sql execution plans. I have a table [User] with the following 3 columns: Id(Primary Key), Username(nvarchar(50)), FirstName(nvarchar(50)) I have Created an Unique NonClustered Index for the Username column The execution plan for a query filtering by FirstName: select * from [User] where...

SQL Queries, execution plans and "Parallelism"

So I'm (still) going through some slow legacy sql views used to do calculate some averages and standarddeviations on a (sometimes) large set of data. What I end up with are views joining views joining views etc. So I though I would review the execution plan for my query. And it immediately suggested a missing index, which I then impleme...

SQL Filegroup degrading performance

On our dev boxes, our database resides entirely in the PRIMARY filegroup, and everything works fine. On one of our production servers, recently upgraded from 2005 to 2008, we noticed it was performing slower than it should. On this machine, there are two filegroups - PRIMARY and INDEXES. Both filegroups contain 1 file per logical vo...

Order of execution of ORDER BY and LIMIT in a MySQL query

Hello all I have a query like this where I want to display sorted records in a paginated format. This is my query. SELECT * FROM answers WHERE userid = '10' ORDER BY votes LIMIT 10, 20 The two arguments to LIMIT will be used for generating page-by-page display of records. Now, my problem is ORDER BY. How does MySQL execute this quer...