April 29, 2008 at 1:59 am
I have created 2 tables in a database which are mostly similar, the table1 will execute with more speed (take only less than or equal to 1 sec) but the table2 will take 4 or 5 secs to execute the query,moreover the similar datas was presented in both the tables. the eg:- query that i have executed is select max(c_code) from table1 and select max(c_code) from table2, the first one take less than 1 sec and the second one take more than 4 or 5 secs, also there is a procedure i hve written to update both the tables, and i got the time out error, if the table1 alone is updated using the procedure it is OK but the table2 alone is updated using the procedure the time out error will be shown, pls reply the reason for this problem as early as possible, it will be a grateful if anybody reply for this trouble?
April 29, 2008 at 5:58 am
To give you a specific answer, sample structures and data and code are necessary. To give you a general answer, take a look at the execution plans for the queries against each table. You'll probably see that Table A is using an index in a seek operation (or something along those lines, again, I can't be specific with a lot more information) and Table B is doing a scan. You may have different data sets in the two tables. You may have different indexes. You may have different statistics on the two tables. You might have different index fragmentation on the two tables. You may have different structures on the two tables. All of these could lead to differences in performance.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
April 29, 2008 at 7:23 am
That covers just about all of it... can't think of anything else to check unless the WHERE clauses have a formula in one and not the other.
--Jeff Moden
Change is inevitable... Change for the better is not.
April 30, 2008 at 11:50 am
Database collation settings could be different too.
Best,
Kevin G. Boles
SQL Server Consultant
SQL MVP 2007-2012
TheSQLGuru on googles mail service
April 30, 2008 at 1:29 pm
And, the tables might be stored in different filegroups or files on different disks that have different performance characteristics or usage profiles.
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply