Click here to Skip to main content
15,889,216 members
Home / Discussions / Database
   

Database

 
GeneralRe: Slow query when using @variable in Where clause [modified] Pin
Meysam Mahfouzi27-Jan-09 20:40
Meysam Mahfouzi27-Jan-09 20:40 
GeneralRe: Slow query when using @variable in Where clause Pin
Wendelius27-Jan-09 20:49
mentorWendelius27-Jan-09 20:49 
GeneralRe: Slow query when using @variable in Where clause Pin
Meysam Mahfouzi27-Jan-09 21:02
Meysam Mahfouzi27-Jan-09 21:02 
GeneralRe: Slow query when using @variable in Where clause Pin
Wendelius27-Jan-09 21:28
mentorWendelius27-Jan-09 21:28 
GeneralRe: Slow query when using @variable in Where clause Pin
Meysam Mahfouzi27-Jan-09 22:41
Meysam Mahfouzi27-Jan-09 22:41 
GeneralRe: Slow query when using @variable in Where clause Pin
Wendelius27-Jan-09 22:59
mentorWendelius27-Jan-09 22:59 
GeneralRe: Slow query when using @variable in Where clause Pin
Meysam Mahfouzi27-Jan-09 23:11
Meysam Mahfouzi27-Jan-09 23:11 
GeneralRe: Slow query when using @variable in Where clause Pin
Wendelius27-Jan-09 23:23
mentorWendelius27-Jan-09 23:23 
What about the parameter question I asked? I was thinking about a solution where you would define a starting point as float. Initial starting point is 0 and you pass how many rows you want per page (for example 10). Next time you call this query, you would specify the starting point as the float found on the last row of the page you got and then again how many rows you want.

So what this means in action is that first you create a new column:
ALTER TABLE News
ADD	StartPoint  AS ((Culture * 100000000) + CONVERT(float, Date))
PERSISTED

Then you index it:
CREATE NONCLUSTERED INDEX X_StartPoint ON News (StartPoint)

Now the query would be like:
DECLARE @Start float, @Count INT
SET @Start = 0
SET @Count = 5
DECLARE @c TINYINT
SET @c = 1;
SELECT TOP(@Count)
       id, title, description, StartPoint
FROM  News a
WHERE Culture = @c
AND   StartPoint > @Start
AND   StartPoint < ((@c + 1) * 100000000)
ORDER BY Start


The need to optimize rises from a bad design.My articles[^]

GeneralRe: Slow query when using @variable in Where clause Pin
Meysam Mahfouzi27-Jan-09 23:59
Meysam Mahfouzi27-Jan-09 23:59 
GeneralRe: Slow query when using @variable in Where clause Pin
Wendelius28-Jan-09 0:21
mentorWendelius28-Jan-09 0:21 
GeneralRe: Slow query when using @variable in Where clause Pin
Meysam Mahfouzi28-Jan-09 1:07
Meysam Mahfouzi28-Jan-09 1:07 
GeneralRe: Slow query when using @variable in Where clause Pin
Wendelius28-Jan-09 1:19
mentorWendelius28-Jan-09 1:19 
GeneralRe: Slow query when using @variable in Where clause Pin
Meysam Mahfouzi28-Jan-09 1:53
Meysam Mahfouzi28-Jan-09 1:53 
GeneralRe: Slow query when using @variable in Where clause Pin
Wendelius28-Jan-09 2:13
mentorWendelius28-Jan-09 2:13 
GeneralRe: Slow query when using @variable in Where clause Pin
Meysam Mahfouzi28-Jan-09 2:56
Meysam Mahfouzi28-Jan-09 2:56 
GeneralRe: Slow query when using @variable in Where clause Pin
Wendelius28-Jan-09 3:12
mentorWendelius28-Jan-09 3:12 
GeneralRe: Slow query when using @variable in Where clause Pin
Meysam Mahfouzi28-Jan-09 3:31
Meysam Mahfouzi28-Jan-09 3:31 
GeneralRe: Slow query when using @variable in Where clause Pin
Wendelius28-Jan-09 4:16
mentorWendelius28-Jan-09 4:16 
GeneralRe: Slow query when using @variable in Where clause Pin
Meysam Mahfouzi28-Jan-09 4:38
Meysam Mahfouzi28-Jan-09 4:38 
GeneralRe: Slow query when using @variable in Where clause Pin
Wendelius28-Jan-09 4:51
mentorWendelius28-Jan-09 4:51 
GeneralRe: Slow query when using @variable in Where clause Pin
Meysam Mahfouzi24-Jun-09 20:46
Meysam Mahfouzi24-Jun-09 20:46 
Questionsql server group Pin
Nath26-Jan-09 17:36
Nath26-Jan-09 17:36 
AnswerRe: sql server group Pin
Wendelius26-Jan-09 18:28
mentorWendelius26-Jan-09 18:28 
QuestionOracle tnsnames.ora "I guess!!" Pin
Muammar©26-Jan-09 8:06
Muammar©26-Jan-09 8:06 
AnswerRe: Oracle tnsnames.ora "I guess!!" Pin
Wendelius26-Jan-09 8:27
mentorWendelius26-Jan-09 8:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.