First Join on TempTable takes 1 second

  • Hi everybody,

    I am working on a rather lengthy stored procedure, which ...

    - first creates a temp table,

    - second inserts values into it and

    - third runs a few queries on it.

    I noticed that after step two, the first query took more than a second, even though the temp table held only 150 rows and the query was an extremly simple join to another regular table with proper index.

    Further test show that without joins, the query executes within a few milliseconds. Outside the stored proc, the query (with joins) also takes only milliseconds. It is only inside the stored procedure "in the flow", i.e. directly after the INSERTS, that a first access to the table joined to another one costs about a second. Execution Plan is fine, too - same inside and outside the stored proc. It must be something behind the query, maybe database enlargement, internal copy activity or the like...

    Any ideas ?

    Environment: SQL7 NT4SP6

  • It might be the way the query is compuiled inside your SP. If number of rows in the perm table is small, then indexes do not matter anyway. You may want to play with hints to speed up the query.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply