Results 1 to 12 of 12
  1. #1
    Join Date
    May 2006
    Posts
    65

    Unanswered: sql query analyser [Microsoft][ODBC SQL Driver]Timeout Expired

    Hi,

    Ive got a collection of view which piece together data from varying sources and assemble it ready for a stored procedure to squirt the data into a table.

    This has worked fine up til yesterday when i had to amend one of the views to include a reference to another data set.

    Essentially the data is for students and comes from our old db and our new one, each year group has different values so the views act to extract all data relevant for a child from both databases and accross all year data sets.

    The problem im having is that i can get the final stored procedure to run. It ran fine the other day but since ive amended one of the views i get timeout errors wherever it's run. real problem when query analyser which has no timeout settings (apparently) times out as it means i cant run the query anywhere....enterprise manager will timeout after 30secs despite amending the query timeout setting to 600s.

    so im a bit stuck, both views which the problem view is trying to combine run in under 30 seconds...when you try and combine them it times out- seems to run for a long long time.

    note sure why this has started happening, from all ive read most peeps get this with EM and solve it using QA. but what if QA cant handle the query either?

    heres the sql: (wont make much sense but hopefully shows that its not a complex query)

    SELECT TOP 100 PERCENT dbo.StudentDetMaster.SetId, dbo.StudentDetMaster.StudentId,
    dbo.StudentDetMaster.Name,
    dbo.StudentDetMaster.CourseYear,
    dbo.StudentDetMaster.House,
    dbo.StudentDetMaster.Tutor,
    dbo.PGJSProfile.[Key Stage 1 Reading],
    dbo.PGJSProfile.[Key Stage 1 Writing],
    dbo.PGJSProfile.[Key Stage 1 Speaking & Listening],
    dbo.PGJSProfile.[Key Stage 1 Maths],
    dbo.PGJSProfile.[Key Stage 2 English],
    dbo.PGJSProfile.[Key Stage 2 Maths],
    dbo.PGJSProfile.[Key Stage 2 Science],
    dbo.PGJSProfile.[Verbal Reasoning Year 3],
    dbo.PGJSProfile.[Year 3 English Autumn],
    dbo.PGJSProfile.[Year 3 English Year Group Average],
    dbo.PGJSProfile.[Year 3 English Summer],
    dbo.PGJSProfile.[Year 3 English Year Group Average Score], dbo.PGJSProfile.[Year 3 Maths Autumn],
    dbo.PGJSProfile.[Year 3 Maths Year Group Average],
    dbo.PGJSProfile.[Year 3 Maths Summer],
    dbo.PGJSProfile.[Year 3 Maths Year Group Average Score], dbo.StudentDetMaster.[Year 3 Maths Set],
    dbo.PGJSProfile.[Verbal Reasoning Year 4],
    dbo.PGJSProfile.[Year 4 English Autumn],
    dbo.PGJSProfile.[Year 4 English Year Group Average],
    dbo.PGJSProfile.[Year 4 English Summer],
    dbo.PGJSProfile.[Year 4 English Year Group Average Score], dbo.PGJSProfile.[Year 4 Maths Autumn],
    dbo.PGJSProfile.[Year 4 Maths Year Group Average],
    dbo.PGJSProfile.[Year 4 Maths Summer],
    dbo.PGJSProfile.[Year 4 Maths Year Group Average Score], dbo.StudentDetMaster.[Year 4 Maths Set],
    dbo.PGJSProfile.[Verbal Reasoning Year 5],
    dbo.PGJSProfile.[Year 5 English Autumn],
    dbo.PGJSProfile.[Year 5 English Year Group Average],
    dbo.PGJSProfile.[Year 5 English Summer],
    dbo.PGJSProfile.[Year 5 English Year Group Average Score], dbo.PGJSProfile.[Year 5 Maths Autumn],
    dbo.PGJSProfile.[Year 5 Maths Year Group Average],
    dbo.PGJSProfile.[Year 5 Maths Summer],
    dbo.PGJSProfile.[Year 5 Maths Year Group Average Score], dbo.StudentDetMaster.[Year 5 Maths Set],
    dbo.PGJSProfile.[Verbal Reasoning Year 6],
    dbo.PGJSProfile.[Year 6 English Autumn],
    dbo.PGJSProfile.[Year 6 English Year Group Average],
    dbo.PGJSProfile.[Year 6 English Year Group Average Score], dbo.PGJSProfile.[Year 6 Maths Autumn],
    dbo.StudentDetMaster.[Year 6 Maths Set],
    dbo.StudentDetMaster.[JS Baseline],
    dbo.PGJSProfile.[Year 6 English Mock],
    dbo.PGJSProfile.[Year 6 Maths Mock],
    dbo.PGJSProfile.[Year 6 English Mock Year Group Average], dbo.PGJSProfile.[Year 6 Maths Mock Year Group Average]
    FROM
    dbo.PGJSProfile LEFT OUTER JOIN
    dbo.StudentDetMaster ON dbo.PGJSProfile.SetId = dbo.StudentDetMaster.SetId AND
    dbo.PGJSProfile.StudentId = dbo.StudentDetMaster.StudentId
    ORDER BY dbo.StudentDetMaster.Name

    cheers

    greg

  2. #2
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Try taking out the TOP 100 PERCENT and the ORDER BY.

    You really should not be depending upon the order in which data is stored in your target table, but if you must have your "squirted" data in a particular order, try making [Name] the clustered index on the target table. Its the only way to guarantee the data stays in that order anyway.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  3. #3
    Join Date
    May 2006
    Posts
    65
    nice one, thanks will sort that.

    greg

  4. #4
    Join Date
    May 2006
    Posts
    65
    the view still times out..is there any settinsg that may be causing QA to timeout early?

    greg

  5. #5
    Join Date
    May 2006
    Posts
    65
    ive checked the query timeout setting in options>connections and its set to 0...

  6. #6
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    do you have indices on your join conditions?
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

  7. #7
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Also - is it possible to post the SQL for PGJSProfile and StudentDetMaster? When you say they both run in under 30 seconds - are they both pushing 30 seconds?
    Testimonial:
    pootle flump
    ur codings are working excelent.

  8. #8
    Join Date
    May 2006
    Posts
    65
    i will but it may the start of a long line of sql views- purely because PGJSProfile and StudentDetMaster reference views themselves....

    StudentDetMaster (pushes 30 secs):

    SELECT dbo.JSKids.Name, dbo.JSKids.StudentId, dbo.JSKids.CourseYear, dbo.JSKids.House, dbo.JSKids.Tutor, dbo.JSKids.SetId,
    dbo.Y3MathsSet.[Year 3 Maths Set], dbo.Y4MathsSet.[Year 4 Maths Set], dbo.Y5MathsSet.[Year 5 Maths Set], dbo.Y6MathsSet.[Year 6 Maths Set],
    dbo.JSBaseline.ValueData AS [JS Baseline]
    FROM dbo.Y4MathsSet RIGHT OUTER JOIN
    dbo.JSKids LEFT OUTER JOIN
    dbo.JSBaseline ON dbo.JSKids.SetId = dbo.JSBaseline.SetId AND dbo.JSKids.StudentId = dbo.JSBaseline.StudentId LEFT OUTER JOIN
    dbo.Y5MathsSet ON dbo.JSKids.StudentId = dbo.Y5MathsSet.StudentId LEFT OUTER JOIN
    dbo.Y3MathsSet ON dbo.JSKids.StudentId = dbo.Y3MathsSet.StudentId ON dbo.Y4MathsSet.StudentId = dbo.JSKids.StudentId LEFT OUTER JOIN
    dbo.Y6MathsSet ON dbo.JSKids.StudentId = dbo.Y6MathsSet.StudentId
    WHERE (dbo.JSKids.SetId = 'Current Ye')

    PGJSProfile now times out- didnt before, its based on two views one which runs in 4 seconds and 1 which runs uin 1 second....

    here is the syntax:

    SELECT dbo.GradesExtract.SetId, dbo.GradesExtract.StudentId, dbo.ProfileExtractCurrent.KS1R AS [Key Stage 1 Reading],
    dbo.ProfileExtractCurrent.KS1W AS [Key Stage 1 Writing], dbo.ProfileExtractCurrent.KS1SP AS [Key Stage 1 Speaking & Listening],
    dbo.ProfileExtractCurrent.KS1M AS [Key Stage 1 Maths], dbo.ProfileExtractCurrent.KS2E AS [Key Stage 2 English],
    dbo.ProfileExtractCurrent.KS2M AS [Key Stage 2 Maths], dbo.ProfileExtractCurrent.KS2SC AS [Key Stage 2 Science],
    dbo.ProfileExtractCurrent.VRY3 AS [Verbal Reasoning Year 3], dbo.ProfileExtractCurrent.VRY4 AS [Verbal Reasoning Year 4],
    dbo.ProfileExtractCurrent.VRY5 AS [Verbal Reasoning Year 5], dbo.ProfileExtractCurrent.VRY6 AS [Verbal Reasoning Year 6],
    dbo.GradesExtract.[Year 3 English Autumn], dbo.GradesExtract.[Year 3 English Year Group Average], dbo.GradesExtract.[Year 3 English Summer],
    dbo.GradesExtract.[Year 3 English Year Group Average Score], dbo.GradesExtract.[Year 3 Maths Autumn],
    dbo.GradesExtract.[Year 3 Maths Year Group Average], dbo.GradesExtract.[Year 3 Maths Summer],
    dbo.GradesExtract.[Year 3 Maths Year Group Average Score], dbo.GradesExtract.[Year 4 English Autumn],
    dbo.GradesExtract.[Year 4 English Year Group Average], dbo.GradesExtract.[Year 4 English Summer],
    dbo.GradesExtract.[Year 4 English Year Group Average Score], dbo.GradesExtract.[Year 4 Maths Autumn],
    dbo.GradesExtract.[Year 4 Maths Year Group Average], dbo.GradesExtract.[Year 4 Maths Summer],
    dbo.GradesExtract.[Year 4 Maths Year Group Average Score], dbo.GradesExtract.[Year 5 English Autumn],
    dbo.GradesExtract.[Year 5 English Year Group Average], dbo.GradesExtract.[Year 5 English Summer],
    dbo.GradesExtract.[Year 5 English Year Group Average Score], dbo.GradesExtract.[Year 5 Maths Autumn],
    dbo.GradesExtract.[Year 5 Maths Year Group Average], dbo.GradesExtract.[Year 5 Maths Summer],
    dbo.GradesExtract.[Year 5 Maths Year Group Average Score], dbo.GradesExtract.[Year 6 English Autumn],
    dbo.GradesExtract.[Year 6 English Year Group Average], dbo.GradesExtract.[Year 6 English Year Group Average Score],
    dbo.GradesExtract.[Year 6 Maths Autumn], dbo.GradesExtract.[Year 6 English Mock], dbo.GradesExtract.[Year 6 Maths Mock],
    dbo.GradesExtract.[Year 6 English Mock Year Group Average], dbo.GradesExtract.[Year 6 Maths Mock Year Group Average]
    FROM dbo.ProfileExtractCurrent INNER JOIN
    dbo.GradesExtract ON dbo.ProfileExtractCurrent.SetId = dbo.GradesExtract.SetId AND
    dbo.ProfileExtractCurrent.StudentId = dbo.GradesExtract.StudentId
    WHERE (dbo.GradesExtract.SetId = 'Current Ye') AND (dbo.GradesExtract.StudentId <> '""')

    probably doesn't make much sense but perhaps a little bit more of what the final table is may help.

    Essentially each student can stay for 6 years in our school, each year a new dataset is created- all students are transferred accross minus any who have left.

    In this way we can have up to 6 datasets to draw info from as a year 1 exam result would be stored in a dataset different to the dataset used when they moved up to year 2. This is because ive inherited a database that has historically worked this way.

    there are also two database the info can come from, the old one and the new one ive set up...the new one has been used for the last 2 years and the old one for the previous 4. therefore to get all info for a year 6 child im having to reference 6 year sets from 2 databases...

    hopefully this will explain why im running long yet uncomplex queries.

    greg

  9. #9
    Join Date
    May 2006
    Posts
    65
    for the moment ive shot the data into two tables; used a view to combine them and then ref'd that view to squirt through to the master table. works pretty quickly which indicates its a problem with stacking views...

    greg

  10. #10
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Hi dubs

    1 db per year is far from optimal but sounds like you are stuck with it. There are those here that will not stand for a view based on a view. Whether or not that is an absolute truth is one for discussion but views within views within views are certainly asking for trouble.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  11. #11
    Join Date
    May 2006
    Posts
    65
    Hi , thought it might be, when i have a decent amount of time i hope to rebuild from the tables up....thing is i dont want to have to start inserting tables into the procedure as before it was all updated immediately and now im having to run two stored procedures- just means its no longer automatic but may have to put up with it...

    greg

  12. #12
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Could it be your network connection that is timing out, rather than Query Analyzer?
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •