Click here to Skip to main content
15,902,492 members
Home / Discussions / Database
   

Database

 
GeneralRe: Getting values from two tables. Pin
Wendelius27-Jan-09 7:59
mentorWendelius27-Jan-09 7:59 
QuestionMultiple Values In single Parameter in oracle Pin
vikram_asv27-Jan-09 5:42
vikram_asv27-Jan-09 5:42 
AnswerRe: Multiple Values In single Parameter in oracle Pin
Wendelius27-Jan-09 6:07
mentorWendelius27-Jan-09 6:07 
QuestionSQL Server 2005 and SQL Server 2008 on the same server Pin
pzn3xq27-Jan-09 4:10
pzn3xq27-Jan-09 4:10 
AnswerRe: SQL Server 2005 and SQL Server 2008 on the same server Pin
Wendelius27-Jan-09 4:46
mentorWendelius27-Jan-09 4:46 
QuestionSlow query when using @variable in Where clause [modified] Pin
Meysam Mahfouzi27-Jan-09 4:06
Meysam Mahfouzi27-Jan-09 4:06 
AnswerRe: Slow query when using @variable in Where clause Pin
Rob Philpott27-Jan-09 4:25
Rob Philpott27-Jan-09 4:25 
GeneralRe: Slow query when using @variable in Where clause Pin
Meysam Mahfouzi27-Jan-09 8:18
Meysam Mahfouzi27-Jan-09 8:18 
GeneralRe: Slow query when using @variable in Where clause [modified] Pin
Meysam Mahfouzi27-Jan-09 20:45
Meysam Mahfouzi27-Jan-09 20:45 
GeneralRe: Slow query when using @variable in Where clause Pin
Rob Philpott27-Jan-09 23:49
Rob Philpott27-Jan-09 23:49 
AnswerRe: Slow query when using @variable in Where clause Pin
Ben Fair27-Jan-09 4:43
Ben Fair27-Jan-09 4:43 
GeneralRe: Slow query when using @variable in Where clause Pin
Meysam Mahfouzi27-Jan-09 8:21
Meysam Mahfouzi27-Jan-09 8:21 
GeneralRe: Slow query when using @variable in Where clause Pin
Ben Fair27-Jan-09 10:50
Ben Fair27-Jan-09 10:50 
AnswerRe: Slow query when using @variable in Where clause Pin
Wendelius27-Jan-09 4:58
mentorWendelius27-Jan-09 4:58 
GeneralRe: Slow query when using @variable in Where clause Pin
Meysam Mahfouzi27-Jan-09 8:14
Meysam Mahfouzi27-Jan-09 8:14 
GeneralRe: Slow query when using @variable in Where clause Pin
Wendelius27-Jan-09 8:36
mentorWendelius27-Jan-09 8:36 
GeneralRe: Slow query when using @variable in Where clause Pin
Meysam Mahfouzi27-Jan-09 9:09
Meysam Mahfouzi27-Jan-09 9:09 
GeneralRe: Slow query when using @variable in Where clause Pin
Wendelius27-Jan-09 9:34
mentorWendelius27-Jan-09 9:34 
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 
Okay, first you could add an index with two columns: Culture, Date DESC:
CREATE INDEX X_Test ON News (Culture, Date DESC);

After that, see what happens for the execution plan (and the performance).

After doing that, you could experiment a change to the query (I suspect that the above modification will not be enough, but if it is, the skip the rest):
SELECT TOP(@Count)
       id, title, description
FROM  News a
WHERE Culture = @c
AND   @Start <= (SELECT COUNT(*)
                 FROM  News b
                 WHERE b.Date < a.Date
                 AND   b.Culture = @c)
ORDER BY Date DESC

Again see execution plan and performance.

Also is the ID column defined as IDENTITY and are the records added to the table in date order. In other words what I'm after, if the identity is greater on one row is it always true that its a newer post based on date column?

If you could post the results for those two operations.

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 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 

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.