Click here to Skip to main content
15,887,683 members
Home / Discussions / Database
   

Database

 
GeneralRe: Help on SQL Crosstab query (VERY SLOW) [modified] Pin
Chandman12-Apr-07 12:19
Chandman12-Apr-07 12:19 
GeneralRe: Help on SQL Crosstab query (VERY SLOW) Pin
DQNOK12-Apr-07 12:30
professionalDQNOK12-Apr-07 12:30 
GeneralRe: Help on SQL Crosstab query (VERY SLOW) Pin
Chandman12-Apr-07 13:22
Chandman12-Apr-07 13:22 
GeneralRe: Help on SQL Crosstab query (VERY SLOW) Pin
Pete O'Hanlon13-Apr-07 1:45
mvePete O'Hanlon13-Apr-07 1:45 
GeneralRe: Help on SQL Crosstab query (VERY SLOW) Pin
Chandman13-Apr-07 8:18
Chandman13-Apr-07 8:18 
GeneralRe: Help on SQL Crosstab query (VERY SLOW) Pin
Pete O'Hanlon13-Apr-07 9:58
mvePete O'Hanlon13-Apr-07 9:58 
GeneralRe: Help on SQL Crosstab query (VERY SLOW) [modified] Pin
DQNOK13-Apr-07 7:13
professionalDQNOK13-Apr-07 7:13 
GeneralRe: Help on SQL Crosstab query (VERY SLOW) Pin
Chandman13-Apr-07 8:10
Chandman13-Apr-07 8:10 
Thank you for you effort on this. You've spend lot of time on this.
I have lot of JOINs and conditions within each sub SELECT query. how many rows did you add to Tests?

When I run my query on a smaller scale (ex: Just Toyotas years 2000-2006) it works fine (max 1 minute wait). When I do something like all SUV's then it goes more than 3 minutes and nobody wants to wait for that long.

Thank you for everyone who tried to help! And here's my conclusion:

DO NOT RUN a CROSSTAB query like this if you have complex database and each table has thousands and thousands of rows and especially if one of the tables has more than 1 million rows. This kind of cross tabbing in MS SQL just WILL NOT WORK (fast enough)! I don't know about other database engines but it seems like the engine SHOULD optimize it for you because compilers such as modern C++ compilers optimize codes. In and IDEAL database engine using this CROSSTAB example it should break down the years into threads and run them seperately - it saves lot of times.
WHY? BECAUSE when I do this query using separately (dividing into smaller pieces by years) and if I run it it takes 10 seconds. Then I build the 2D table out of all this sub queries using any programming language - it takes another 10-20 seconds. So I'm going back to my old method.

It also brings up another question:
Can you do threads in MS SQL query and do some sort of wait on those? I figured it should do it in the background because all it takes is one semester worth of class with a project. I mean, the Microsoft operating systems are capable of doing threads (so it runs), so why they shouldn't integrate it into the SQL server? It's not a rocket science!

CORRECT ME IF I'M WRONG. I COULD BE!!!
GeneralRe: Help on SQL Crosstab query (VERY SLOW) Pin
DQNOK13-Apr-07 8:30
professionalDQNOK13-Apr-07 8:30 
GeneralRe: Help on SQL Crosstab query (VERY SLOW) [modified] Pin
Chandman13-Apr-07 10:35
Chandman13-Apr-07 10:35 
Questiongetting data in parts Pin
ArchaBhandare12-Apr-07 2:11
ArchaBhandare12-Apr-07 2:11 
AnswerRe: getting data in parts Pin
Pete O'Hanlon12-Apr-07 2:16
mvePete O'Hanlon12-Apr-07 2:16 
GeneralRe: getting data in parts Pin
Chandman12-Apr-07 6:51
Chandman12-Apr-07 6:51 
GeneralRe: getting data in parts Pin
Pete O'Hanlon12-Apr-07 9:23
mvePete O'Hanlon12-Apr-07 9:23 
AnswerRe: getting data in parts Pin
Elina Blank12-Apr-07 3:58
sitebuilderElina Blank12-Apr-07 3:58 
GeneralRe: getting data in parts Pin
ArchaBhandare12-Apr-07 18:47
ArchaBhandare12-Apr-07 18:47 
GeneralRe: getting data in parts Pin
Elina Blank13-Apr-07 3:58
sitebuilderElina Blank13-Apr-07 3:58 
Questioni have problem Pin
Shuaib wasif khan12-Apr-07 0:42
Shuaib wasif khan12-Apr-07 0:42 
AnswerRe: i have problem Pin
Pete O'Hanlon12-Apr-07 1:24
mvePete O'Hanlon12-Apr-07 1:24 
GeneralRe: i have problem Pin
Paul Conrad12-Apr-07 7:09
professionalPaul Conrad12-Apr-07 7:09 
QuestionProblem In Date In sql Query Pin
Tirthadip11-Apr-07 23:43
Tirthadip11-Apr-07 23:43 
AnswerRe: Problem In Date In sql Query Pin
Shuaib wasif khan11-Apr-07 23:47
Shuaib wasif khan11-Apr-07 23:47 
Questionhow to count how many proc resides in database Pin
Shuaib wasif khan11-Apr-07 23:30
Shuaib wasif khan11-Apr-07 23:30 
AnswerRe: how to count how many proc resides in database Pin
gauthee12-Apr-07 0:11
gauthee12-Apr-07 0:11 
GeneralRe: how to count how many proc resides in database Pin
Shuaib wasif khan12-Apr-07 0:32
Shuaib wasif khan12-Apr-07 0:32 

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.